import Vue from 'vue'
import Vuex from 'vuex'
import MenuList from '../model/CurdMethods'
Vue.use(Vuex)

const store = new Vuex.Store({
  state: {
    menuList: new MenuList()
  },
  mutations: {
    Add(state: any, obj: any) {
      state.menuList.Add(obj)
    },
    Edit(state: any, obj: any){
      state.menuList.Edit(obj)
    },
    Del(state: any, obj: any){
      state.menuList.Del(obj)
    },
    Cate(state:any,isCate:number){
      if(isCate==0 || isCate==1 || isCate==2){
        state.menuList.MenuList = state.menuList.Read().filter((item:any)=>{
          return isCate === item.isCate
        })
      }else{
        state.menuList.MenuList = state.menuList.Read()
      }
    }
  }
})
export default store
